package com.hysf.aspects;

import com.hysf.project1.Person;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Order(1)
public class MyAspects {
	@Pointcut ("execution(* com.hysf.project1.PersonBizImpl.addPerson(..))")
	public void p1() {}
	
	@Before(value = "p1()")
	public void privilege() {
		System.out.println("权限校验");
	}
	
	@AfterReturning(value = "p1()", returning = "result")
	public void log(Person result) {
		System.out.println("日志记录");
		if (result != null) {
			System.out.println("新增的人是：" + result);
		}
	}
	
	@AfterThrowing (value = "p1()", throwing = "e")
	public void exception(Exception e) {
		System.out.println("异常处理");
		System.out.println("异常信息：" + e.getMessage());
	}
}
